-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Coverage][NFC] Avoid visiting non-unique OpaqueValueExpr
#88910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Coverage][NFC] Avoid visiting non-unique OpaqueValueExpr
#88910
Conversation
Only unique `OpaqueValueExpr`s should be handled in the mapping builder, as discussed in llvm#85837. However, `getCond()` returns non-unique `OpaqueValueExpr` for `BinaryConditionalOperator` (because it is also used as the "true" branch expression). Use `getCommon()` instead so as to bypass the `OpaqueValueExpr`.
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Andrey Ali Khan Bolshakov (bolshakov-a) ChangesOnly unique @efriedma-quic Full diff: https://github.com/llvm/llvm-project/pull/88910.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 71215da362d3d0..64c39c5de351c7 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -2011,11 +2011,13 @@ struct CounterCoverageMappingBuilder
Counter TrueCount = llvm::EnableSingleByteCoverage
? getRegionCounter(E->getTrueExpr())
: getRegionCounter(E);
-
- propagateCounts(ParentCount, E->getCond());
Counter OutCount;
- if (!isa<BinaryConditionalOperator>(E)) {
+ if (const auto *BCO = dyn_cast<BinaryConditionalOperator>(E)) {
+ propagateCounts(ParentCount, BCO->getCommon());
+ OutCount = TrueCount;
+ } else {
+ propagateCounts(ParentCount, E->getCond());
// The 'then' count applies to the area immediately after the condition.
auto Gap =
findGapAreaBetween(E->getQuestionLoc(), getStart(E->getTrueExpr()));
@@ -2024,8 +2026,6 @@ struct CounterCoverageMappingBuilder
extendRegion(E->getTrueExpr());
OutCount = propagateCounts(TrueCount, E->getTrueExpr());
- } else {
- OutCount = TrueCount;
}
extendRegion(E->getFalseExpr());
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Could you merge it please? |
Looks like automation didn't trigger for some reason... but quoting the automated message that's supposed to trigger:
|
Done. |
Only unique
OpaqueValueExpr
s should be handled in the mapping builder, as discussed in #85837. However,getCond()
returns non-uniqueOpaqueValueExpr
forBinaryConditionalOperator
(because it is also used as the "true" branch expression). UsegetCommon()
instead so as to bypass theOpaqueValueExpr
.@efriedma-quic